Fix missing booking confirmation emails for anonymous visitors - #24
Open
gonengar wants to merge 1 commit into
Open
Fix missing booking confirmation emails for anonymous visitors#24gonengar wants to merge 1 commit into
gonengar wants to merge 1 commit into
Conversation
The site automation that sends the confirmation email fires on sessions_booked and gates on notify_participants=true and a non-null contact_id from the booking record. The previous flow left both empty: participantNotification was only set on confirmBooking (which doesn't backfill the booking entity at create-time), and the booking's contact link was left to async resolution from the anonymous visitor identity. - Pre-create the CRM contact with appendOrCreateContact and pass the returned contactId on booking.contactDetails.contactId. Same email returns the same contactId, so this is idempotent. - Set participantNotification.notifyParticipants on createBooking so the flag persists on the entity and the trigger sees it. - Switch the server-side confirm route from confirmBooking to confirmOrDecline with paymentStatus PAID, matching the offline payment path. Also set selectedPaymentOption OFFLINE at create-time so the booking record reflects a properly paid offline booking. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Anonymous visitors who booked an appointment were never receiving the confirmation email, even though the booking record showed
status: CONFIRMED. The site already has the preinstalled "Send clients an email confirmation when they book" automation (active), but its trigger gate evaluated false on every booking we created.The automation fires on
wix_bookings-sessions_bookedand is gated by:Inspecting recent bookings on the live site showed each one missing one or more of these signals:
confirmBooking-only path)sessions_bookedalready fired)appendOrCreateContactChanges
src/components/BookEngineer.tsx— beforecreateBooking:submittedContact.appendOrCreateContactto upsert the CRM contact and resolve a realcontactId.contactDetails.contactIdintocreateBookingso the booking is linked at create-time rather than relying on async resolution from the anonymous visitor identity.participantNotification: { notifyParticipants: true, message }as the secondcreateBookingarg so thenotify_participantsflag persists on the booking entity (this is what the trigger reads — confirm-time notifications don't backfill it).selectedPaymentOption: "OFFLINE"so the booking record reflects the actual payment path.src/pages/api/bookings/confirm.ts— switch fromconfirmBookingtoconfirmOrDeclinewithpaymentStatus: "PAID"via an elevatedhttpClient.fetchWithAuthcall (the SDK doesn't yet exposeconfirmOrDeclineon the auto-SDK we use). Matches the offline-paid flow.Test plan
paymentStatus: PAID,selectedPaymentOption: OFFLINE,participantNotification.notifyParticipants: true, and a non-nullcontactDetails.contactId.contactId, no duplicate CRM contact).🤖 Generated with Claude Code